<%@ page language="java" contentType="text/html; charset=UTF-8"
	pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<script type="text/javascript">
	function delete1(obj){
		if(confirm("정말로 삭제하시겠습니까?")==true){
			return true;
		}else{
			return false;
	}
}
</script>
<table width="600" border="0" cellspacing="0" cellpadding="1" align="center">
	<tr>
		<td colspan="4" align="center" style="height: 35px"><font style="font-weight: bold;font-size: 20pt">Parking Board</font></td>
	</tr>
	<tr>
		<td width="100" bgcolor="#EAEAEA">글번호</td>
		<td width="200">${board.b_num}</td>
		<td width="100" bgcolor="#EAEAEA">조회수</td>
		<td width="200">${board.b_hits}</td>
	</tr>
	<tr>
		<td width="100" bgcolor="#EAEAEA">글쓴이</td>
		<td width="200">${board.m_id}</td>
		<td width="100" bgcolor="#EAEAEA">등록날짜</td>
		<td width="200">${board.b_date}</td>
	</tr>
	<tr>
		<td bgcolor="#EAEAEA">제목</td>
		<td colspan="3">${board.b_title}</td>
	</tr>
	<tr>
		<td colspan="4">
			<hr size="1" width="100%" noshade="noshade">
		</td>
	</tr>
	<tr>
		<td colspan="4">${board.b_content}</td>
	</tr>
	<tr>
		<td colspan="4">
			<hr size="1" width="100%" noshade="noshade">
		</td>
	</tr>
	<tr>
		<td bgcolor="#EAEAEA">첨부파일</td>
		<td colspan="3"><a href="boardFile.do?filename=${board.b_filename}">${board.b_filename}</a></td>
	</tr>
	<tr>
		<td align="right" colspan="4">
	<c:if test="${userId == board.m_id || userLevel == '9'}">
		<input type="button" value="수정" onclick="location.href='updateBoard.do?b_num=${board.b_num}'">
		<input type="button" value="삭제" onclick="location.href='deleteBoard.do?b_num=${board.b_num}'">
		</c:if>
		<input type="button" value="목록" onclick="location.href='boardList.do'"></td>
	</tr>
	<tr align="center">
		<td colspan="4"><hr size="0" width="100%" noshade="noshade"></td>
	</tr>
</table>

<form action="replyList.do" method="post">
	<input type="hidden" value="${userId }" name="m_id"> <input
		type="hidden" value="${board.b_num}" name="b_num">

	<!-- 댓글테이블 -->
	<table width="600" border="0" cellspacing="0" cellpadding="0"
		align="center">
		<tr>
			<td colspan="2">작성자 : ${userId}</td>
		</tr>
		<tr>
			<td colspan="1" width="500"><textarea rows="5" cols="80"
					name="r_content" style="resize:none"></textarea></td>
			<td><input type="submit" value="댓글달기" style="height: 80px;width: 80px"></td>
		</tr>
		<tr>
			<td colspan="2">
				<hr size="1" width="100%" noshade="noshade">
			</td>
		</tr>
	</table>
</form>
<c:if test="${count > 0}">
	<table width="600" border="0" cellspacing="0" cellpadding="0" align="center">
		<tr bgcolor="#f3f3f3">
		</tr>
		<c:forEach var="reply" items="${rlist}">
			<tr>
				<td width="100" bgcolor="#bbbbbb">아이디</td>
				<td width="200">${reply.m_id }</td>
				<td width="100" bgcolor="#bbbbbb">등록날짜</td>
				<td align="center" width="200">${reply.r_date }</td>
			</tr>
			<tr>
				<td colspan="4">${reply.r_content }</td>
			</tr>
			<tr>
			<td colspan="4" align="right">
					<form:form action="replyModify.do" method="post">
						<input type="hidden" name="b_num" value="${reply.b_num}">
						<input type="hidden" name="r_num" value="${reply.r_num}">
						<input type="submit" value="수정" herf="replyModify.do">
					</form:form>
				</td>
				<td colspan="4" align="right">
				<form:form action="deleteModify.do" method="post">
						<c:if test="${userId == board.m_id || userId == reply.m_id}">
						<input type="hidden" name="b_num" value="${reply.b_num}">
						<input type="hidden" name="r_num" value="${reply.r_num}">
						<input type="button" value="수정">
					</c:if>	
				</form:form>
				<td colspan="4" align="right">
					<form:form action="deleteReply.do" method="post">
					<c:if test="${userId == board.m_id || userId == reply.m_id}">
						<input type="hidden" name="b_num" value="${reply.b_num}">
						<input type="hidden" name="r_num" value="${reply.r_num}">
						<input type="submit" value="삭제" onclick="delete1(this)">
					</c:if>
					</form:form>
				</td>

				</td>
				</tr>
			<tr>
				<td colspan="4">
					<hr size="1" width="100%" noshade="noshade">
				</td>
			</tr>
		</c:forEach>
	</table>
</c:if>